package com.ym.health.api.others;

import com.ym.common.constant.Constants;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.medical.domain.entity.InformationEntity;
import com.ym.medical.enums.InformationInforStateEnum;
import com.ym.medical.service.IInformationSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 平台公告、医生接单后回复了你的消息、退款成功通知、医生发布的新话题Controller
 *
 * @author ym
 * @date 2020-08-21
 */
@Api(tags = "medical-平台公告、医生接单后回复了你的消息、退款成功通知、医生发布的新话题")
@RestController
@Validated
@RequestMapping(value = "/others/Information", headers = Constants.Api.VERSION)
public class InformationController extends BaseController {

	@Autowired
	private IInformationSV informationSV;



	@ApiOperation("获取平台公告、医生接单后回复了你的消息、退款成功通知、医生发布的新话题详细信息")
	@Log
	@GetMapping(value = "/info")
	public APIResponse<InformationEntity> info(@RequestParam Long id) {
		InformationEntity data = informationSV.selectById(id);
		return successData(data);
	}

	@ApiOperation("设置为已读")
	@Log
	@GetMapping(value = "/setRead")
	public APIResponse setRead(@RequestParam Long id) {
		InformationEntity build = InformationEntity
				.builder()
				.inforState(InformationInforStateEnum.OVER_READ.getKey())
				.build();
		build.setId(id);
		informationSV.updateById(build);
		return success();
	}

}
